from selenium import webdriver
from selenium.webdriver.common.by import By
from time import sleep

driver = webdriver.Firefox()
url = 'file:///D:/nsd2404/html/registerA.html'
driver.get(url)
# XPATH定位：绝对路径定位  /  不能跨层级定位
# 相对路径： // 可以跳跃到任意层级
# /html/body/form/div/fieldset/p[1]/input
# 遇到多个，可以使用下标访问，下标从1开始
# 结合元素属性
username = driver.find_element(By.XPATH, '/html/body/form/div/fieldset/p[@id="p1"]/input')
username.send_keys('admin')
# 定位密码和电话号码
password = driver.find_element(By.XPATH, '/html/body/form/div/fieldset/p[2]/input')
password.send_keys('123456')
# * 匹配任意元素
tel = driver.find_element(By.XPATH, '//*[@id="telA"]')
tel.send_keys('17788889999')
# //input[@name="emailA"]
# //*[@id="emailA"]
email = driver.find_element(By.XPATH, '//input[@name="emailA" and @id="emailA"]')
email.send_keys('admin@163.com')
sleep(3)
driver.quit()



